<aside class="main-sidebar">

    <section class="sidebar">
        <!-- search form -->
        <form action="#" method="get" class="sidebar-form">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="搜索..."/>
              <span class="input-group-btn">
                <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
            </div>
        </form>
        <!-- /.search form -->

        <?= dmstr\widgets\Menu::widget(
            [
                'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
                'items' => [
                    ['label' => '功能列表', 'options' => ['class' => 'header']],
                    ['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
                    [
                        'label' => '权限控制',
                        'icon' => 'fa fa-gears',
                        'url' => '#',
                        'items' => [
                            // ['label' => '管理员', 'icon' => 'file-code-o', 'url' => ['/admin'],],
                            // [
                            //     'label' => '权限',
                            //     'icon' => 'fa fa-circle-o',
                            //     'url' => '/user',
                            //     'items' => [
                            //         ['label' => '路由', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/route'],],
                            //         ['label' => '权限', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/permission'],],
                            //         ['label' => '角色', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/role'],],
                            //         ['label' => '分配', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/assignment'],],
                            //         ['label' => '菜单', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/menu'],],
                            //     ],
                            // ],
                            ['label' => '路由', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/route'],],
                            ['label' => '权限', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/permission'],],
                            ['label' => '角色', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/role'],],
                            ['label' => '分配', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/assignment'],],
                            ['label' => '菜单', 'icon' => 'fa fa-circle-o', 'url' => ['/admin/menu'],],
                        ],
                    ],
                ],
            ]
        ) ?>


        <?php
        use mdm\admin\components\MenuHelper;
        $callback = function($menu){
            $data = json_decode($menu['data'], true);
            $items = $menu['children'];
            $return = [
                'label' => $menu['name'],
                'url' => [$menu['route']],
            ];
            //处理我们的配置
            if ($data) {
                //visible
                isset($data['visible']) && $return['visible'] = $data['visible'];
                //icon
                isset($data['icon']) && $data['icon'] && $return['icon'] = $data['icon'];
                //other attribute e.g. class...
                $return['options'] = $data;
            }
            //没配置图标的显示默认图标，默认图标大家可以自己随便修改
            (!isset($return['icon']) || !$return['icon']) && $return['icon'] = 'circle-o';
            $items && $return['items'] = $items;

            return $return;
        };

        //这里我们对一开始写的菜单menu进行了优化
        echo dmstr\widgets\Menu::widget( [
            // 'options' => ['class' => 'sidebar-menu tree'],
            'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
            'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id, null, $callback),
        ] ); ?>
    </section>

</aside>
